68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138

'
'
' ***** GetSmallestSize *****
'
SUB GetSmallestSize
  XuiSendMessage (grid, #GetBorder, 0, 0, 0, 0, $XuiDialog2B, @bw)
  XuiSendMessage (grid, #GetSmallestSize, 0, 0, @labelWidth, @labelHeight, $Label, 8)
  XuiSendMessage (grid, #GetSmallestSize, 0, 0, @textWidth, @textHeight, $TextLine, 8)
'
  FOR i = $Button0 TO $Button1
    XuiSendMessage (grid, #GetSmallestSize, 0, 0, @width, @height, i, 8)
    IF (width > buttonWidth) THEN buttonWidth = width
    IF (height > buttonHeight) THEN buttonHeight = heigh
  NEXT i
'
  width = buttonWidth + buttonWidth
  IF (width < labelWidth) THEN width = labelWidth
  v2 = width + bw + bw
  v3 = labelHeight + buttonHeight + textHeight + bw + bw
END SUB
'
'
' ***** Resize *****
'
SUB Resize
  vv2 = v2
  vv3 = v3
  GOSUB GetSmallestSize     ' returns bw and heights
  v2 = MAX (vv2, v2)
  v3 = MAX (vv3, v3)
'
  XuiPositionGrid (grid, @v0, @v1, @v2, @v3)
'
  h = labelHeight + buttonHeight + textHeight + bw + bw
  IF (v3 >= h + 4) THEN
    buttonHeight = buttonHeight + 4 : h = h + 4
    IF (v3 >= h + 4) THEN textHeight = textHeight + 4
  END IF
'
  labelWidth = v2 - bw - bw
  labelHeight = v3 - buttonHeight - textHeight - bw - bw
  buttonWidth = labelWidth >> 1
  w0 = buttonWidth
  w1 = labelWidth - w0
'
  x = v0 + bw
  y = v1 + bw
  w = labelWidth
  XuiSendMessage (grid, #Resize, x, y, w, labelHeight, $Label, 0)
'
  y = y + labelHeight
  XuiSendMessage (grid, #Resize, x, y, w, textHeight, $TextLine, 0)
'
  h = buttonHeight
  y = y + textHeight
  XuiSendMessage (grid, #Resize, x, y, w0, h, $Button0, 0) : x = x + w0
  XuiSendMessage (grid, #Resize, x, y, w1, h, $Button1, 0) : x = x + w1
  XuiResizeWindowToGrid (grid, #ResizeWindowToGrid, v0, v1, v2, v3, 0, 0)
END SUB
'
'
' ***** Selection *****
'
SUB Selection
  SELECT CASE r0
    CASE $XuiDialog2B :
    CASE $TextLine    :
    CASE $Button0     :
    CASE $Button1     :
  END SELECT
END SUB